package com.orange.controller;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.orange.handler.AuthCatalogService;
import com.orange.modules.entity.AuthCatalog;
import com.orange.util.ReturnCode;

@Controller
@RequestMapping("/catalog")
public class AuthCatalogController extends BaseController{
	
	private static final Logger logger = Logger.getLogger(AuthCatalogController.class);
	
	@Autowired
	private AuthCatalogService authCatalogService;
	
	/**
	 * 目录查询
	 * @param request
	 * @param map
	 * @return
	 * @throws SQLException
	 */
	@RequestMapping(value = "/queryAuthCatalog" ,produces = MediaType.APPLICATION_JSON_VALUE+";charset=UTF-8", method=RequestMethod.POST)
	@ResponseBody
	public ResponseEntity<String> queryAuthCatalog(HttpServletRequest request,@RequestBody Map<String ,String> map) throws SQLException{
		String fid = map.get("fid");
		if(fid==null || StringUtils.isBlank(fid))
			return toResponse(null,ReturnCode.PARAMETER_NOT_NULL,"父ID不能为空!");
		List<AuthCatalog> ac = authCatalogService.queryCatalog(fid);
		return toResponse(ac,ReturnCode.SUCCESS,"查询成功");
	}
	
}
